/**
 * @file CreateGroupChatHandler.cs
 * @author Zane Mayo
 * @date 26/5/2009
 */

using System;
using System.Collections.Generic;

namespace MxitAPI {
	
	
	public class CreateGroupChatHandler : Handler {
		
		private static log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );
		
		private string roomName;
		// Todo calculate the number of contacts automatically
		private int numContacts;
		private List<int> contactIds;
		// Todo Remove, debugging only
		public List<string> contactAddresses;
		
		
		public CreateGroupChatHandler() : base( typeof( CreateGroupChatProtocolMessage ) )  {
		}
		
		public CreateGroupChatHandler( string roomName, int numContacts, List<int> contactIds ) : this()  {
			this.roomName = roomName;
			this.numContacts = numContacts;
			this.contactIds = contactIds;
		}
		
		public override ProtocolMessage CreateRequestProtocolMessage() {
			CreateGroupChatProtocolMessage protocolMessage = new CreateGroupChatProtocolMessage();
			protocolMessage.RoomName = roomName;
			protocolMessage.NumContacts = numContacts;
			
			// Create the list of contact addresses from the list of contact Ids
			/*List<string> contactAddresses =  new List<string>();
			foreach ( int contactId in contactIds ) {
				contactAddresses.add( Contacts.Instance.GetContact( contactId ).ContactAddress );
			}*/
			
			protocolMessage.ContactAddresses = contactAddresses;
			
			return protocolMessage;
		}
		
		protected override void HandleSpecificResponseProtocolMessage ( ProtocolMessage protocolMessage ) {
			CreateGroupChatProtocolMessage createGroupChatProtocolMessage = ( CreateGroupChatProtocolMessage ) protocolMessage;
			// Todo Handle the room id
			log.Debug( "Group chat created, room id : " + createGroupChatProtocolMessage.RoomId );
		}

		
	}
}